package com.srv.model.json;

import java.util.ArrayList;
import java.util.Date;

import org.codehaus.jackson.map.ObjectMapper;

import com.srv.model.Node;
import com.srv.model.Travel;

/**
 * 
 * @author Administrator
 *
 */
public class Node_Json4Owner implements java.io.Serializable,JSON_UTF8{
	
	public Node_Json4Owner(Node theNode){
		this.id=theNode.nodeID;
		this.img_public_URI=theNode.img_public_URI;
		this.record_public_URI=theNode.record_public_URI;
		this.createTime=theNode.createTime;
		this.updateTime=theNode.updateTime;
		this.favorNum=theNode.favorNum;
		this.downloadNum=theNode.downloadNum;
		this.rePubNum=theNode.rePubNum;
		this.textContext=theNode.textContext;
	}
	/**
	 * ID
	 */
    public String id = null;
    /**
     * 图片URI(对外公开)
     */
    public String img_public_URI = null;
    
    /**
     * 录音URI(对外公开)
     */
    public String record_public_URI = null;
    
    /**
	 * 收藏次数
	 */
    public long favorNum = 0;
    /**
	 * 下载次数
	 */
    public long downloadNum = 0;
    /**
	 * 转发次数
	 */
    public long rePubNum = 0;
    
    /**
     * 文本描述
     */
    public String textContext = null;
    
    /**
     * 创建时间
     */
    public Date createTime = null;
    /**
     * 更新时间
     */
    public Date updateTime = null;
    
    /**
	 * 转换成UTF-8的Json
	 * @return
	 */
    public String toJson_utf8() throws Exception{
    	ObjectMapper mapper = new ObjectMapper();
        mapper.registerSubtypes(Node_Json4Owner.class);
    	return mapper.writeValueAsString(this);    	                
    }
    /**
     * 转换
     * @param travelArrayList
     * @return
     */
    public static ArrayList<Node_Json4Owner> convert(ArrayList<Node> nodeArrayList){
    	ArrayList al=new ArrayList();
    	for(int i=0; i<nodeArrayList.size();i++){
    		al.add(new Node_Json4Owner(nodeArrayList.get(i)));
    	}
    	return al;
    }
    public static void main(String[] args) throws Exception{
    	 	
    	Node theNode = new Node();
    	theNode.nodeID="121323331";    	
//    	theNode.img_public_URI=new ArrayList();
//    	theNode.img_public_URI.add("/img/111.jpg");
//    	theNode.img_public_URI.add("/img/112.jpg");
//    	theNode.img_public_URI.add("/img/113.jpg");
//    	theNode.img_public_URI.add("/img/114.jpg");
//    	
//    	theNode.record_public_URI=new ArrayList();
//    	theNode.record_public_URI.add("/img/111.mp3");
//    	theNode.record_public_URI.add("/img/112.mp3");
//    	theNode.record_public_URI.add("/img/113.mp3");
//    	theNode.record_public_URI.add("/img/114.mp3");
//    	theNode.createTime=new Date();
//    	theNode.updateTime=new Date();
//    	theNode.textContext="我们都是好朋友";
    	
    	System.out.println((new Node_Json4Owner(theNode)).toJson_utf8());
    }
}
